package main

import (
	"flag"
	"npm/app"
	"npm/utils"
	"os"
)

var (
	mod  string
	dir  string
	conf string
)

func main() {
	flag.StringVar(&mod, "m", "d", "执行的模块")
	flag.StringVar(&dir, "path", "", "前端项目所在路径")
	flag.StringVar(&conf, "c", "", "配置文件地址")
	flag.Parse()

	if dir == "" || conf == "" {
		flag.Usage()
		os.Exit(0)
	}

	utils.Conf = utils.ParseConfig(&conf)

	switch mod {
	case "upload":
		_ = app.UploadRun(dir)
		break
	case "d":
		_ = app.DownRun(dir)
		//ctx := context.Background()
		//_ = utils.Install(ctx, dir)
		break
	case "json":
		_ = app.PackageJSONDownRun(dir)
		//ctx := context.Background()
		//_ = utils.Install(ctx, dir)
		break
	case "dall":
		_ = app.DownAllRun(dir)
		break
	default:
		flag.Usage()
	}

	os.Exit(0)
}
